import { z } from "zod";

export const LoginSchema = z.object({
  email: z.string().email({ message: "请输入合法的邮箱" }),
  password: z.string().min(6, { message: "密码长度不能小于6位" }),
});

export type TLoginSchema = z.infer<typeof LoginSchema>;

export const RegisterSchema = LoginSchema.extend({
  rePassword: z.string().min(6, { message: "密码长度不能小于6位" }),
}).refine(
  (data) => {
    return data.password === data.rePassword;
  },
  {
    message: "两次密码不一致",
    path: ["rePassword"],
  },
);

export type TRegisterSchema = z.infer<typeof RegisterSchema>;
